package com.tech.platform.cms.admin.controller;

import com.tech.platform.cms.admin.dao.pojo.User;
import com.tech.platform.cms.admin.service.UserService;
import com.tech.platform.cms.common.model.CommonResult;
import com.tech.platform.cms.common.model.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/admin/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public CommonResult<String> add(User user){
        return userService.add(user);
    }

    @RequestMapping(value = "/page",method = RequestMethod.GET)
    public PageResult<List<User>> page(int current,int size,int status,String keyword){
        return userService.page(current,size,status,keyword);
    }

    @RequestMapping(value = "/update",method = RequestMethod.PUT)
    public CommonResult<String> update(User user){
        return userService.update(user);
    }
}
